package com.d.ui.view.recordtrigger;


import com.d.lib.common.widget.TitleLayout;
import com.d.lib.ui.view.recordtrigger.RecordLightView;
import com.d.lib.ui.view.recordtrigger.RecordTriggerView;
import com.d.ui.view.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

/**
 * Created by D on 2017/11/1.
 */
public class RecordTriggerActivity extends AbilitySlice {
  private RecordTriggerView rtv_trigger;
  private RecordLightView rlv_light;


  @Override
  protected void onStart(Intent intent) {
    super.onStart(intent);
    setUIContent(ResourceTable.Layout_activity_recordtrigger);
    rtv_trigger = (RecordTriggerView) findComponentById(ResourceTable.Id_rtv_trigger);
    rlv_light = (RecordLightView) findComponentById(ResourceTable.Id_rlv_light);
    TitleLayout titleLayout = (TitleLayout) findComponentById(ResourceTable.Id_tl_title);
    titleLayout.setBackClickListener(this::onBackClick);

    rtv_trigger.setOnTriggerListener(new RecordTriggerView.OnTriggerListener() {
      @Override
      public void onStateChange(int state) {
        rlv_light.setState(state);
      }
    });
  }


  public void onBackClick(Component component) {
    terminate();
  }


}
